#include <iostream>

using namespace std;
int b[2][10000];
int n;

int calbit1(int k)
{
    int sum = 0;
    while (k > 0)
    {
        if (k % 2 == 1) sum++;
        k /= 2;
    }
    return sum;
}

int hex2bin(int k)
{
    int res = 0, p = 1;
    while (k > 0)
    {
        res += (k%10) * p;
        k /= 10;
        p = p << 4;
    }
    return res;
}

void process()
{
    for (int i = 0; i < 10000; i++)
    {
        b[0][i] = calbit1(i);
        int j = hex2bin(i);
        b[1][i] = calbit1(j);
    }
}

int main()
{
    process();
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int m;
        cin >> m;
        cout << b[0][m] << " " << b[1][m] << endl;
    }
    return 0;
}
